from math import factorial
for _ in range(int(input())):
    n = int(input())
    a = int(input())
    b = int(input())
    if factorial(n) % (pow(a, b)) == 0:
        print("Yes")
    else:
        print("No")
